package com.ganjingcun.roma.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.ganjingcun.roma.persist.dao.PlaceDao;
import com.ganjingcun.roma.persist.model.Place;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by GanJc on 2016/4/17.
 */
@RestController
@RequestMapping(value = "/api",produces="application/json;charset=UTF-8")
public class ApiController {

    @RequestMapping(value = "/getPlace", method = RequestMethod.GET)
    public String getPlace(Integer page) {
        System.out.println("page:" + page);
        PlaceDao placeDao = new PlaceDao();
        List<Place> placeList = placeDao.getPlaceList(page);
        JSONObject json = new JSONObject();
        json.put("last",placeList.size()<10);
        json.put("page",page);
        json.put("placeList", placeList);
        return json.toJSONString();
    }
}
